﻿#include "CMakeProject_2_List.h"

using namespace std;

void testNode();
void testLinkedList();

int main()
{
	/* Node test */
	/* head->node->tail->head */

	testLinkedList();
	//cout << "Hello CMake." << endl;
	return 0;
}

void testNode() {
	/* Node test */
	/* head->node->tail->head */

	Node<int>* head = new Node(HEAD, 0);
	Node<int>* tail = new Node(TAIL, 0);
	Node<int>* node = new Node(NORMAL, 1, head, tail);
	head->setNext(node);
	head->setPrev(tail);
	tail->setNext(head);
	tail->setPrev(node);

	/* test success ! */

	node->printString();

	node->~Node();
}

void testLinkedList() {
	LinkedList<int>* linkedList1 = new LinkedList<int>();
	LinkedList<int>* linkedList2 = new LinkedList<int>();
	for (int i = 0; i < 10; i++)
	{
		linkedList1->addToTail(i + 1);
		linkedList2->addToHead(i + 1);
	}
	cout << "linkedlist1" << endl;
	linkedList1->printString();
	linkedList1->getHead()->printString();
	linkedList1->getTail()->printString();

	cout << endl << endl;
	cout << "linkedlist2" << endl;
	linkedList2->printString();
	linkedList2->getHead()->printString();
	linkedList2->getTail()->printString();

	cout << endl << endl;
	cout << "node1" << endl;
	Node<int>* node1 = linkedList1->get(4);
	node1->printString();

	cout << endl << endl;
	cout << "node2" << endl;
	Node<int>* node2 = linkedList1->selectFirstNode(5);
	node2->printString();

	cout << endl << endl;
	cout << "remove node 1" << endl;
	linkedList1->remove(node1);
	linkedList1->printString();
}
